package com.quasar.hpatient.module.mine_qrcode;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.widget.ImageView;

import com.quasar.hpatient.R;

import lib.quasar.base.frame.BasePresenter;
import lib.quasar.context.BaseApp;
import lib.quasar.qrcode.ZXingUtil;
import lib.quasar.widget.image.BitmapImageView;

/**
 * description: 我 ==> 我的二维码
 * created by kalu on 2018/7/16 16:47
 */
public final class MineQrcodePresenter implements BasePresenter {

    final void loadQrcode(MineQrcodeView view, BitmapImageView image) {

        if (null == view || null == image)
            return;

        final Bitmap iconBitmap = BitmapFactory.decodeResource(BaseApp.getResource(), R.mipmap.ic_launcher);
        if (null == iconBitmap) return;

        final Bitmap qrcodeBitmap = ZXingUtil.createQRCodeWithLogo("18791984289", iconBitmap);
        if (null == qrcodeBitmap) return;

//        image.setOnImageChangeListener(() -> {
//            if (null != iconBitmap) {
//                iconBitmap.recycle();
//            }
//
//            if (null != qrcodeBitmap) {
//                qrcodeBitmap.recycle();
//            }
//        });
        image.setImageBitmap(qrcodeBitmap);
    }

    @Override
    public void recycler() {
    }
}
